package com.brsya.movie.activity;

import android.os.Bundle;
import android.view.View;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;

import com.brsya.base.base.BaseLayoutActivity;
import com.brsya.base.base.Contents;
import com.brsya.movie.R;
import com.brsya.movie.fragment.FindFragment;

/**
 * Created by Brsya
 * CreateDate: 2022/7/6  17:58
 * Description:
 * 发现页面
 */
public class FindActivity extends BaseLayoutActivity {

    private FindFragment findFragment;

    private String movieType;
    private String movieSort;
    private int initSelectIndex;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fragment_box);
        initView();
    }

    private void initView() {

        if (getIntent() != null) {
            initSelectIndex = getIntent().getIntExtra(Contents.INTENT_FIND_SELECT, 0);
            if (getIntent().getStringExtra(Contents.INTENT_MOVIE_TYPE) != null) {
                movieType = getIntent().getStringExtra(Contents.INTENT_MOVIE_TYPE);
            }
            if (getIntent().getStringExtra(Contents.INTENT_MOVIE_SORT) != null) {
                movieSort = getIntent().getStringExtra(Contents.INTENT_MOVIE_SORT);
            }
        }

        findFragment = FindFragment.newInstance(initSelectIndex, movieType, movieSort, true);
        findFragment.setOnBackListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.add(R.id.fl_home_fragment_box
                , findFragment);
        fragmentTransaction.commit();

    }
}
